home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / mee / vbdao / visdata / attach.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  10.3 KB  |  365 lines

  1. VERSION 2.00
  2. Begin Form fAttach 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Attach Table"
  6.    ClientHeight    =   3345
  7.    ClientLeft      =   1455
  8.    ClientTop       =   2010
  9.    ClientWidth     =   7455
  10.    Height          =   3750
  11.    Left            =   1395
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3345
  14.    ScaleWidth      =   7455
  15.    Top             =   1665
  16.    Width           =   7575
  17.    Begin TextBox cDatasource 
  18.       Height          =   285
  19.       Left            =   1995
  20.       TabIndex        =   2
  21.       Tag             =   "OLS"
  22.       Top             =   945
  23.       Width           =   3690
  24.    End
  25.    Begin PictureBox Picture1 
  26.       BackColor       =   &H00FFFFFF&
  27.       Height          =   3150
  28.       Left            =   5775
  29.       ScaleHeight     =   3120
  30.       ScaleWidth      =   1560
  31.       TabIndex        =   20
  32.       Tag             =   "OLS"
  33.       Top             =   120
  34.       Width           =   1590
  35.       Begin OptionButton Option1 
  36.          BackColor       =   &H00FFFFFF&
  37.          Caption         =   "FoxPro 2.5"
  38.          Height          =   330
  39.          Index           =   4
  40.          Left            =   105
  41.          TabIndex        =   23
  42.          Top             =   1680
  43.          Width           =   1380
  44.       End
  45.       Begin OptionButton Option1 
  46.          BackColor       =   &H00FFFFFF&
  47.          Caption         =   "FoxPro 2.0"
  48.          Height          =   330
  49.          Index           =   3
  50.          Left            =   120
  51.          TabIndex        =   10
  52.          Top             =   1365
  53.          Width           =   1380
  54.       End
  55.       Begin OptionButton Option1 
  56.          BackColor       =   &H00FFFFFF&
  57.          Caption         =   "dBase IV"
  58.          Height          =   330
  59.          Index           =   2
  60.          Left            =   120
  61.          TabIndex        =   9
  62.          Top             =   1080
  63.          Width           =   1380
  64.       End
  65.       Begin OptionButton Option1 
  66.          BackColor       =   &H00FFFFFF&
  67.          Caption         =   "ODBC"
  68.          Height          =   330
  69.          Index           =   7
  70.          Left            =   105
  71.          TabIndex        =   13
  72.          Top             =   2730
  73.          Width           =   1380
  74.       End
  75.       Begin OptionButton Option1 
  76.          BackColor       =   &H00FFFFFF&
  77.          Caption         =   "Btrieve"
  78.          Height          =   330
  79.          Index           =   6
  80.          Left            =   105
  81.          TabIndex        =   12
  82.          Top             =   2370
  83.          Width           =   1380
  84.       End
  85.       Begin OptionButton Option1 
  86.          BackColor       =   &H00FFFFFF&
  87.          Caption         =   "Paradox 3.X"
  88.          Height          =   330
  89.          Index           =   5
  90.          Left            =   105
  91.          TabIndex        =   11
  92.          Top             =   2010
  93.          Width           =   1380
  94.       End
  95.       Begin OptionButton Option1 
  96.          BackColor       =   &H00FFFFFF&
  97.          Caption         =   "dBase III"
  98.          Height          =   330
  99.          Index           =   1
  100.          Left            =   105
  101.          TabIndex        =   8
  102.          Top             =   720
  103.          Width           =   1380
  104.       End
  105.       Begin OptionButton Option1 
  106.          BackColor       =   &H00FFFFFF&
  107.          Caption         =   "MS Access"
  108.          Height          =   330
  109.          Index           =   0
  110.          Left            =   105
  111.          TabIndex        =   7
  112.          Top             =   420
  113.          Value           =   -1  'True
  114.          Width           =   1380
  115.       End
  116.       Begin Label Label1 
  117.          BackColor       =   &H00FFFFFF&
  118.          Caption         =   "Data Type:"
  119.          Height          =   225
  120.          Index           =   4
  121.          Left            =   105
  122.          TabIndex        =   21
  123.          Top             =   105
  124.          Width           =   1065
  125.       End
  126.    End
  127.    Begin TextBox cDatabase 
  128.       Height          =   285
  129.       Left            =   1995
  130.       TabIndex        =   1
  131.       Tag             =   "OLS"
  132.       Top             =   525
  133.       Width           =   3690
  134.    End
  135.    Begin CheckBox cExclusive 
  136.       BackColor       =   &H00C0C0C0&
  137.       Caption         =   "Open Exclusive"
  138.       Height          =   225
  139.       Left            =   3150
  140.       TabIndex        =   6
  141.       Top             =   2310
  142.       Width           =   2325
  143.    End
  144.    Begin CheckBox cSavePassword 
  145.       BackColor       =   &H00C0C0C0&
  146.       Caption         =   "Save Password"
  147.       Height          =   225
  148.       Left            =   315
  149.       TabIndex        =   5
  150.       Top             =   2310
  151.       Width           =   2640
  152.    End
  153.    Begin CommandButton CancelBtn 
  154.       Cancel          =   -1  'True
  155.       Caption         =   "&Close"
  156.       Height          =   435
  157.       Left            =   3255
  158.       TabIndex        =   15
  159.       Top             =   2730
  160.       Width           =   1905
  161.    End
  162.    Begin CommandButton OkayBtn 
  163.       Caption         =   "&OK"
  164.       Default         =   -1  'True
  165.       Enabled         =   0   'False
  166.       Height          =   435
  167.       Left            =   630
  168.       TabIndex        =   14
  169.       Top             =   2730
  170.       Width           =   1905
  171.    End
  172.    Begin ComboBox cTableName 
  173.       Height          =   300
  174.       Left            =   1995
  175.       TabIndex        =   4
  176.       Tag             =   "OLS"
  177.       Top             =   1785
  178.       Width           =   3690
  179.    End
  180.    Begin TextBox cConnect 
  181.       Height          =   285
  182.       Left            =   1995
  183.       TabIndex        =   3
  184.       Tag             =   "OLS"
  185.       Top             =   1365
  186.       Width           =   3690
  187.    End
  188.    Begin TextBox cAttachName 
  189.       Height          =   285
  190.       Left            =   1995
  191.       TabIndex        =   0
  192.       Tag             =   "OLS"
  193.       Top             =   105
  194.       Width           =   3690
  195.    End
  196.    Begin Label Label1 
  197.       BackColor       =   &H00C0C0C0&
  198.       Caption         =   "ODBC DataSource:"
  199.       Height          =   225
  200.       Index           =   5
  201.       Left            =   105
  202.       TabIndex        =   22
  203.       Top             =   945
  204.       Width           =   1800
  205.    End
  206.    Begin Label Label1 
  207.       BackColor       =   &H00C0C0C0&
  208.       Caption         =   "Database Name:"
  209.       Height          =   225
  210.       Index           =   3
  211.       Left            =   105
  212.       TabIndex        =   19
  213.       Top             =   525
  214.       Width           =   1800
  215.    End
  216.    Begin Label Label1 
  217.       BackColor       =   &H00C0C0C0&
  218.       Caption         =   "Table to Attach:"
  219.       Height          =   225
  220.       Index           =   2
  221.       Left            =   105
  222.       TabIndex        =   18
  223.       Top             =   1785
  224.       Width           =   1800
  225.    End
  226.    Begin Label Label1 
  227.       BackColor       =   &H00C0C0C0&
  228.       Caption         =   "Connect String:"
  229.       Height          =   225
  230.       Index           =   1
  231.       Left            =   105
  232.       TabIndex        =   17
  233.       Top             =   1365
  234.       Width           =   1800
  235.    End
  236.    Begin Label Label1 
  237.       BackColor       =   &H00C0C0C0&
  238.       Caption         =   "Attachment Name:"
  239.       Height          =   225
  240.       Index           =   0
  241.       Left            =   105
  242.       TabIndex        =   16
  243.       Top             =   105
  244.       Width           =   1800
  245.    End
  246. Sub CancelBtn_Click ()
  247.   Unload Me
  248. End Sub
  249. Sub cAttachName_Change ()
  250.   If Len(cAttachName) > 0 Then
  251.     OkayBtn.Enabled = True
  252.   Else
  253.     OkayBtn.Enabled = False
  254.   End If
  255.   If cTableName.ListCount > 0 Then cTableName.Clear
  256. End Sub
  257. Sub cConnect_Change ()
  258.   If Len(cAttachName) > 0 Then
  259.     OkayBtn.Enabled = True
  260.   Else
  261.     OkayBtn.Enabled = False
  262.   End If
  263.   If cTableName.ListCount > 0 Then cTableName.Clear
  264. End Sub
  265. Sub cTableName_DropDown ()
  266.   Dim d As Database
  267.   Dim i As Integer
  268.   Dim dt As String       'data type string
  269.   On Error GoTo DDErr
  270.   SetHourglass Me
  271.   If cTableName.ListCount = 0 Then
  272.     If Option1(0) Then
  273.       dt = ";"
  274.     ElseIf Option1(1) Then
  275.       dt = "dBASE III;"
  276.     ElseIf Option1(2) Then
  277.       dt = "dBASE IV;"
  278.     ElseIf Option1(3) Then
  279.       dt = "FoxPro 2.0;"
  280.     ElseIf Option1(4) Then
  281.       dt = "FoxPro 2.5;"
  282.     ElseIf Option1(5) Then
  283.       dt = "Paradox;"
  284.     ElseIf Option1(6) Then
  285.       dt = "Btrieve;"
  286.     ElseIf Option1(7) Then
  287.       dt = "ODBC;"
  288.     End If
  289.     If Len(cDatabase) > 0 Then
  290.       dt = dt & "database=" & cDatabase
  291.     End If
  292.     If Len(cDatasource) > 0 Then
  293.       dt = dt & ";dsn=" & cDatasource
  294.     End If
  295.     Set d = OpenDatabase(NULL_STR, 0, 0, dt & ";" & cConnect & ";LoginTimeout=" & glLoginTimeout)
  296.     For i = 0 To d.TableDefs.Count - 1
  297.       If (d.TableDefs(i).Attributes And DB_SYSTEMOBJECT) = 0 Then
  298.         cTableName.AddItem d.TableDefs(i).Name
  299.       End If
  300.     Next
  301.   End If
  302.   ResetMouse Me
  303.   GoTo DDEnd
  304. DDErr:
  305.   ResetMouse Me
  306.   ShowError
  307.   Resume DDEnd
  308. DDEnd:
  309. End Sub
  310. Sub Form_Paint ()
  311.   Outlines Me
  312. End Sub
  313. Sub OkayBtn_Click ()
  314.   On Error GoTo okerr
  315.   Dim d As Database
  316.   Dim dt As String         'data type string
  317.   Dim tbl As New TableDef
  318.   SetHourglass Me
  319.   If Option1(0) Then
  320.     dt = ";"
  321.   ElseIf Option1(1) Then
  322.     dt = "dBASE III;"
  323.   ElseIf Option1(2) Then
  324.     dt = "dBASE IV;"
  325.   ElseIf Option1(3) Then
  326.     dt = "FoxPro 2.0;"
  327.   ElseIf Option1(4) Then
  328.     dt = "FoxPro 2.5;"
  329.   ElseIf Option1(5) Then
  330.     dt = "Paradox;"
  331.   ElseIf Option1(6) Then
  332.     dt = "Btrieve;"
  333.   ElseIf Option1(7) Then
  334.     dt = "ODBC;"
  335.   End If
  336.   If Len(cDatabase) > 0 Then
  337.     dt = dt & "database=" & cDatabase
  338.   End If
  339.   If Len(cDatasource) > 0 Then
  340.     dt = dt & ";dsn=" & cDatasource
  341.   End If
  342.   'set the properties
  343.   tbl.Name = cAttachName
  344.   tbl.SourceTableName = cTableName
  345.   tbl.Connect = dt & ";" & cConnect
  346.   If cSavePassword = 1 Then
  347.     tbl.Attributes = &H20000
  348.   End If
  349.   If cExclusive = 1 Then
  350.     tbl.Attributes = tbl.Attributes + &H10000
  351.   End If
  352.   gCurrentDB.TableDefs.Append tbl
  353.   RefreshTables fTables.cTableList, True
  354.   ResetMouse Me
  355.   cAttachName = NULL_STR
  356.   cTableName = NULL_STR
  357.   GoTo OKEnd
  358. okerr:
  359.   ResetMouse Me
  360.   ShowError
  361.   Resume OKEnd
  362. OKEnd:
  363. '  Unload Me
  364. End Sub
  365.